<?php
namespace App\Services;

class MatchService extends Service
{


    public function raw($pattern,$content)
    {
        $pattern = '/'.$pattern.'/';
        preg_match($pattern,$content,$matches);
        return $matches[1] ?? null;
    }


    //匹配图片url
    public function findImg($content)
    {
        preg_match_all('/<img.*?src="(.*?)"/i', $content, $matches);
        return $matches[1] ?? [];
    }

    //匹配a链接
    public function findHref($content)
    {
        preg_match_all('/<a.*?href="(.*?)".*?>/i', $content, $matches);

        return $matches[1] ?? [];
    }


}
